package com.wehealth.biz_ecg.dialog

import android.view.Gravity
import android.view.LayoutInflater
import android.view.WindowManager
import android.view.animation.AnimationUtils
import androidx.fragment.app.FragmentManager
import com.wehealth.biz_ecg.R
import com.wehealth.biz_ecg.databinding.DialogLoadingLayoutBinding
import com.wehealth.three.lib_connect.base.BaseBottomDialog

class LoadingDialog(var text: String, private val supportFragmentManager: FragmentManager) :
    BaseBottomDialog<DialogLoadingLayoutBinding>() {
    override fun getLayoutId(): Int {
        return R.layout.dialog_loading_layout
    }

    override fun widthLayoutManager(): Int {
        return WindowManager.LayoutParams.WRAP_CONTENT
    }

    override fun heightLayoutManager(): Int {
        return WindowManager.LayoutParams.MATCH_PARENT
    }

    override fun setGravity(): Int {
        return Gravity.TOP
    }

    override fun initBinding(inflater: LayoutInflater) {
        val hyperspaceJump = AnimationUtils.loadAnimation(requireContext(), R.anim.progerss)
        dataBinding?.loadingProgress?.startAnimation(hyperspaceJump)
        dataBinding?.loadingText?.text = text

    }


    fun closeDialog() {
        this.dismiss()
    }


    fun openDialog() {
        this.show(supportFragmentManager, "loading")
    }
}